home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Demo.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-12-16  |  2.3 KB  |  110 lines

  1. package symantec.itools.demo;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Component;
  5. import java.awt.FlowLayout;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.awt.LayoutManager;
  9. import symantec.itools.awt.util.Util;
  10.  
  11. public abstract class Demo extends Applet {
  12.    protected String title;
  13.    protected boolean isApplet;
  14.    protected DemoFrame frame;
  15.    protected int xPos;
  16.    protected int yPos;
  17.    protected int width;
  18.    protected int height;
  19.  
  20.    public Demo(String var1, int var2, int var3, int var4, int var5) {
  21.       this.title = var1;
  22.       this.xPos = var2;
  23.       this.yPos = var3;
  24.       this.width = var4;
  25.       this.height = var5;
  26.    }
  27.  
  28.    public void init() {
  29.       this.isApplet = true;
  30.       this.setup();
  31.       this.frame.show();
  32.    }
  33.  
  34.    protected void driver() {
  35.       this.isApplet = false;
  36.       this.setup();
  37.       this.frame.show();
  38.    }
  39.  
  40.    protected void setup() {
  41.       this.frame = new DemoFrame(this, this.title);
  42.       this.frame.reshape(this.xPos, this.yPos, this.width, this.height);
  43.       this.frame.setLayout(new FlowLayout());
  44.    }
  45.  
  46.    public void endDemo() {
  47.       if (this.isApplet) {
  48.          ((Applet)this).stop();
  49.       } else {
  50.          System.exit(0);
  51.       }
  52.    }
  53.  
  54.    public void cleanup() {
  55.       this.frame.hide();
  56.       this.frame.dispose();
  57.    }
  58.  
  59.    public void doExit() {
  60.       this.cleanup();
  61.       this.endDemo();
  62.    }
  63.  
  64.    public void doHelp() {
  65.    }
  66.  
  67.    public void doAbout() {
  68.    }
  69.  
  70.    public void doRestart() {
  71.       this.cleanup();
  72.       this.setup();
  73.    }
  74.  
  75.    public Component add(Component var1) {
  76.       return this.frame.add(var1);
  77.    }
  78.  
  79.    public synchronized Component add(Component var1, int var2) {
  80.       return this.frame.add(var1, var2);
  81.    }
  82.  
  83.    public synchronized Component add(String var1, Component var2) {
  84.       return this.frame.add(var1, var2);
  85.    }
  86.  
  87.    public void setLayout(LayoutManager var1) {
  88.       if (this.frame != null) {
  89.          this.frame.setLayout(var1);
  90.       }
  91.  
  92.    }
  93.  
  94.    public Graphics getGraphics() {
  95.       return this.frame.getGraphics();
  96.    }
  97.  
  98.    public Font getFont() {
  99.       Font var2;
  100.       if (this.frame != null) {
  101.          var2 = this.frame.getFont();
  102.          var2 = var2 == null ? Util.getDefaultFont() : var2;
  103.       } else {
  104.          var2 = Util.getDefaultFont();
  105.       }
  106.  
  107.       return var2;
  108.    }
  109. }
  110.